//
//  BaseViewController.m
//  yilutongxing
//
//  Created by zjs on 17/3/10.
//  Copyright © 2017年 YZE. All rights reserved.
//

#import "BaseViewController.h"


@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initHeadView];
    
}

-(void)initHeadView{
    _m_headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64)];
    [self.view addSubview:_m_headView];
    
    /*
    _m_btnBack = [[UIButton alloc] initWithFrame:CGRectMake(0, 22, 46, 40)];
    [_m_btnBack setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [_m_btnBack setImage:[UIImage imageNamed:@"back_selected"] forState:UIControlStateSelected];
    [_m_btnBack addTarget:self action:@selector(btnBack:) forControlEvents:UIControlEventTouchUpInside];
    [_m_headView addSubview:_m_btnBack];
     */
    
    _m_labelTitle = [[UILabel alloc] init];
    [_m_headView addSubview:_m_labelTitle];
    [_m_labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_m_headView).with.offset(22);
        make.right.equalTo(_m_headView.mas_right).with.offset(-100);
        make.left.equalTo(_m_headView.mas_left).with.offset(100);
        make.height.mas_equalTo(@40);
    }];
    [_m_labelTitle setTextColor:[UIColor blackColor]];
    _m_labelTitle.font = [UIFont systemFontOfSize:18];
    _m_labelTitle.textAlignment = NSTextAlignmentCenter;
    
    
    self.navibar_bottom_line = [[UIView alloc] initWithFrame:CGRectMake(0, 63.5, SCREEN_WIDTH, 0.5)];
    self.navibar_bottom_line.backgroundColor = [UIColor grayColor];
    [_m_headView addSubview:self.navibar_bottom_line];
    
    
}

-(void)creat_fabu_btn{
    _fabu_btn=[[UIButton alloc]init];
   
     [_m_headView addSubview:_fabu_btn];
        [_fabu_btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_m_headView).with.offset(22);
            make.right.equalTo(_m_headView.mas_right).with.offset(-20);
            make.height.mas_equalTo(@40);
            make.left.equalTo(_m_labelTitle.mas_right).with.offset(20);
        }];
    [self.fabu_btn setTitleColor:Bluecolor forState:UIControlStateNormal];
    [_fabu_btn setTitle:@"发布" forState:UIControlStateNormal];
    [_fabu_btn addTarget:self action:@selector(fabu_click) forControlEvents:UIControlEventTouchUpInside];

}

-(void)fabu_click{
    NSNotificationCenter *center=[NSNotificationCenter defaultCenter];
    
    [center postNotificationName:@"fabu_btn_click" object:self userInfo:nil];

}

-(void)btnBack:(UIButton*)btn{
    
    [[YZENetwork sharedInstace] cancelNetwork];
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark 网络请求回调
-(void)OnStartWithRequestTag:(int)tag{
    [UIView showActivityViewWithView:self.view msg:nil];
}

-(void)OnSuccess:(id)responseObject requestTag:(int)tag{
    
}

-(void)OnFail:(NSString *)errorMsg errorCode:(NSInteger)errorCode requestTag:(int)tag{
    [UIView showToastWithMessage:[errorMsg isNotEmpty]?errorMsg:@"您的网络太不给力了" andViewController:self];
}

-(void)OnFinishWithRequestTag:(int)tag{
    [UIView hideActivityView];
}
@end
